package com.yanqu.road.server.cmd.activity.relation;

import com.yanqu.road.entity.rank.ServerRank;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.cross.activity.CrossActivityProto;
import com.yanqu.road.pb.rank.RankProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.relation.CrossRelationRankMgr;
import com.yanqu.road.server.protocol.Protocol;

import java.math.BigInteger;

@Cmd(code = Protocol.C_CROSS_RELATION_ACTIVITY_SERVER_RANK_CHANGE, desc = "跨服区服排行数据变化")
public class CrossRelationServerRankChangeCmd extends CrossCommand {

    private int activityId;

    private boolean isAll;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossActivityProto.CrossActivityRankChangeReqMsg reqMsg = CrossActivityProto.CrossActivityRankChangeReqMsg.parseFrom(packet.getBytes());
        isAll = reqMsg.getIsAll();
        activityId = reqMsg.getActivityId();
        for(RankProto.RankTempMsg temMsg : reqMsg.getDataListList()) {
            ServerRank serverRank = new ServerRank();
            serverRank.setServerId(serverId);
            BigInteger value = new BigInteger(temMsg.getValue());
            serverRank.setValue(value);
            CrossRelationRankMgr.changeRelationServerRank(activityId, serverRank);
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
